package com.chengqj.template;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.util.ArrayList;
import java.util.List;

/**
 * @program: pattern
 * @description: Oracle连接数据库
 * @author: chengqj
 * @create: 2018-07-30 19:17
 **/
public class OracleJDBCTemplate extends AbstractJdbcTemplate{
    @Override
    protected Connection getConnection() {
        String url = "jdbc:oracle:thin:@//127.0.0.1:1521/orcl"; //连接字符串
        String username = "system"; //用户名
        String password = "123456"; //密码
        try{
            Class.forName("oracle.jdbc.driver.OracleDriver");
            Connection conn = DriverManager.getConnection(url, username, password);
            return  conn;
        }catch (Exception e){
            e.printStackTrace();
        }
        return null;
    }
    @Override
    protected List<?> parseResultSet(ResultSet rs) {
        System.out.println("mysql执行 parseResultSet");
        List<String> resultList = new ArrayList<>();
        try{
            while (rs.next()) {
                resultList.add(rs.getString("oraclecolumnName"));
            }
        }catch (Exception e){
            e.printStackTrace();
        }
        return resultList;
    }

}
